$(document).ready(function() {
	var height = $(window).height();
//	height -= 10;
//	var width = $(window).width();
	$('#page').css('min-height', height);
//	$('.footer').css('width', width);

	var name = "#floatBtn";  
	var btnYloc = null;  

$("#floatBtn").show();
  
    btnYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")));  
    $(window).scroll(function () {   
        var offset = btnYloc+$(document).scrollTop()+"px";  
        $(name).animate({top:offset},{duration:500,queue:false});  
    });  


//	$.get('SQL_basics.php', function(data) {
//		$('#page .right-side').html(data);
//	});	
/*
	$('#li1').bind('click', function() {
            var elem = $(this);
            $.get('index.php', function(data) { 
                //$('#page .right-side').html(data);
                
                togglebckg('#li1');
            });

	});		
	$('#li2').bind('click', function() {
		$.get('CreateData.php', function(data) {
		    //$('#page .right-side').html(data);
                togglebckg('#li2');    
		});
	});
	$('#li3').bind('click', function() {
		$.get('SelectData.php', function(data) {
		    $('#page .right-side').html(data);
                togglebckg('#li3');    
		});
	});
    $('#li4').bind('click', function() {
        $.get('InsertData.php', function(data) {
            $('#page .right-side').html(data);
                togglebckg('#li4');    
        });
    });
*/    
    $('#li5').bind('click', function() {
        $.get('UpdateData.php', function(data) {
            $('#page .right-side').html(data);
                togglebckg('#li5');    
        });
    }); 
    $('#li6').bind('click', function() {
        $.get('DeleteData.php', function(data) {
            $('#page .right-side').html(data);
                togglebckg('#li6');    
        });
    });   
    $('#li9').bind('click', function() {
        $.get('ForeignKeys.php', function(data) {
            $('#page .right-side').html(data);
            togglebckg('#li9');    
        });
    });


//    if (window.document.location.pathname == '/egles/index.php') {
	if (window.document.location.search =='?result_tbl') {
	    $.get('CreateTable.php', function(data) {
		$('#page .right-side').html(data);
            });
        }
//    }
//    else if (window.document.location.pathname == '/egles/index.php') {
	else if (window.document.location.search =='?result_select') {
	    $.get('SELECTresult.php', function(data) {
		  $('#page .right-side').html(data);
        });
    }
    else if (window.document.location.search =='?result_insert') {
            //alert('radau');
        $.get('INSERTresult.php', function(data) {
          $('#page .right-side').html(data);
        });
    }
    else if (window.document.location.search =='?result_update') {
            //alert('radau');
        $.get('UPDATEresult.php', function(data) {
          $('#page .right-side').html(data);
        });
    }
    else if (window.document.location.search =='?result_delete') {
            //alert('radau');
        $.get('DELETEresult.php', function(data) {
          $('#page .right-side').html(data);
        });
    }
  //  } 
    else {
        $.get('index.php', function(data) {
            //$('#page .right-side').html(data);
        });
    }   
        
        
});

var togglebckg = function(elem){
    $('#page .left-side span').css('font-weight', 'normal');
    $('#page .left-side span'+elem).css('font-weight', 'bold');
}

function btnClick(btn){
    if ($("#teorija1").is(':visible')) {
     // $("#test1").slideUp();
        $("#teorija1").slideUp("slow");
        $("#btn1").toggle();       
        $("#btn2").toggle();
        $("#btn3").toggle();
        $("#test1").toggle("slow");
       
    } else {
         $("#teorija1").show("slow");
    }
}
function btn2Click(btn){
    if ($("#teorija1").is(':hidden')) {
        $("#teorija1").slideDown("slow");
        $("#btn1").toggle();
        $("#btn2").toggle();
        $("#btn3").toggle();         
    }
}

function btnClick2(btn){
    if ($(".bigtbl").is(':hidden')) {
        $(".bigtbl").slideDown("slow");

        $("#btn5").toggle();       
        $("#btn4").toggle();
       
    } 
}
function btn2Click2(btn){
    if ($(".bigtbl").is(':visible')) {
        $(".bigtbl").slideUp("slow");
        $("#btn4").toggle();
        $("#btn5").toggle();
    }
}
